package com.TwinBlade.PicturePassword;

import android.annotation.SuppressLint;
import android.app.AlarmManager;
import android.app.KeyguardManager;
import android.app.KeyguardManager.KeyguardLock;
import android.app.Notification;
import android.app.PendingIntent;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Build.VERSION;
import android.os.Bundle;
import android.os.IBinder;
import android.os.PowerManager;
import android.preference.PreferenceManager;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
import android.view.Display;
import android.view.WindowManager;
import java.util.Calendar;

public class AService extends Service
  implements SharedPreferences.OnSharedPreferenceChangeListener
{
  public static final BroadcastReceiver a = new c();
  private static Context d;
  private KeyguardManager.KeyguardLock b;
  private SharedPreferences c;
  private AlarmManager e;
  private PendingIntent f;
  private boolean g = false;
  private boolean h = false;
  private boolean i = false;
  private long j = 0L;
  private boolean k = true;
  private boolean l = false;
  private final BroadcastReceiver m = new a(this);
  private final PhoneStateListener n = new b(this);

  private void a(int paramInt)
  {
    if (!this.c.getBoolean("StockLockDuringDelay", true))
    {
      KeyguardManager localKeyguardManager = (KeyguardManager)getSystemService("keyguard");
      if (this.b == null)
      {
        this.b = localKeyguardManager.newKeyguardLock(getClass().toString());
        this.b.disableKeyguard();
      }
    }
    this.e = ((AlarmManager)getSystemService("alarm"));
    Intent localIntent = new Intent("StartLockscreenDelayed");
    this.f = PendingIntent.getBroadcast(d, 0, localIntent, 268435456);
    Calendar localCalendar = Calendar.getInstance();
    localCalendar.setTimeInMillis(System.currentTimeMillis());
    localCalendar.add(13, paramInt);
    this.e.set(0, localCalendar.getTimeInMillis(), this.f);
    this.g = true;
  }

  private void a(boolean paramBoolean, String paramString)
  {
    this.g = false;
    if (bl.a())
      return;
    if (!bl.b())
      bl.a(d, true).b(paramBoolean);
    while (true)
    {
      if ((bl.b()) && (this.c.getBoolean("UpdateTimeBackground", false)))
        bl.a(d, false).a(false);
      Utilities.a("Service Start Lock w/ Source: " + paramString);
      return;
      bl.a(d, false).e(false);
    }
  }

  private boolean b()
  {
    int i1 = ((WindowManager)d.getSystemService("window")).getDefaultDisplay().getRotation();
    return (i1 == 1) || (i1 == 3);
  }

  @SuppressLint({"InlinedApi"})
  private boolean c()
  {
    if (Build.VERSION.SDK_INT < 9);
    while ((0xF & getResources().getConfiguration().screenLayout) != 4)
      return false;
    return true;
  }

  public IBinder onBind(Intent paramIntent)
  {
    return null;
  }

  public void onCreate()
  {
    super.onCreate();
    IntentFilter localIntentFilter = new IntentFilter("android.intent.action.SCREEN_OFF");
    localIntentFilter.addAction("android.intent.action.SCREEN_ON");
    localIntentFilter.addAction("com.android.deskclock.ALARM_ALERT");
    localIntentFilter.addAction("com.android.deskclock.ALARM_DONE");
    localIntentFilter.addAction("android.intent.action.CAMERA_BUTTON");
    localIntentFilter.addAction("StartLockscreenDelayed");
    localIntentFilter.addAction("com.teslacoilsw.widgetlocker.intent.UNLOCKED");
    localIntentFilter.addAction("com.teslacoilsw.widgetlocker.intent.LOCKED");
    localIntentFilter.addAction("com.teslacoilsw.widgetlocker.intent.HIDDEN");
    registerReceiver(this.m, localIntentFilter);
    ((TelephonyManager)getSystemService("phone")).listen(this.n, 32);
    d = this;
    this.c = PreferenceManager.getDefaultSharedPreferences(this);
    this.c.registerOnSharedPreferenceChangeListener(this);
    if (bd.a(this))
      this.h = this.c.getBoolean("LockAfterWidgetLocker", false);
    Utilities.a = false;
  }

  public void onDestroy()
  {
    try
    {
      unregisterReceiver(this.m);
      try
      {
        label8: unregisterReceiver(a);
        label15: ((TelephonyManager)getSystemService("phone")).listen(this.n, 0);
        return;
      }
      catch (Exception localException2)
      {
        break label15;
      }
    }
    catch (Exception localException1)
    {
      break label8;
    }
  }

  public void onSharedPreferenceChanged(SharedPreferences paramSharedPreferences, String paramString)
  {
    if ((paramString.equals("ForegroundService")) || (paramString.equals("TransparentNotificationIcon")))
    {
      stopSelf();
      startService(new Intent(this, AService.class));
    }
    while ((!paramString.equals("LockAfterWidgetLocker")) || (!bd.a(d)))
      return;
    this.h = this.c.getBoolean("LockAfterWidgetLocker", false);
  }

  public int onStartCommand(Intent paramIntent, int paramInt1, int paramInt2)
  {
    boolean bool1 = this.c.getBoolean("ForegroundService", true);
    boolean bool2 = this.c.getBoolean("TransparentNotificationIcon", false);
    int i1;
    Bundle localBundle;
    if (bool1)
    {
      if (bool2)
      {
        i1 = 2130837510;
        Notification localNotification = new Notification(i1, "Lockscreen Service Started", System.currentTimeMillis());
        localNotification.setLatestEventInfo(this, "PicturePassword", "Lockscreen service is running", PendingIntent.getActivity(this, 0, new Intent(this, Main.class), 0));
        startForeground(2, localNotification);
      }
    }
    else if (paramIntent != null)
    {
      localBundle = paramIntent.getExtras();
      if (localBundle != null)
      {
        if (!localBundle.getBoolean("OnBoot"))
          break label142;
        a(true, "on boot");
      }
    }
    label142: 
    while ((!localBundle.getBoolean("TaskerStart")) || (((PowerManager)getSystemService("power")).isScreenOn()))
    {
      return 1;
      i1 = 2130837509;
      break;
    }
    a(true, "tasker");
    return 1;
  }
}

/* Location:           D:\Studium\Bachelorarbeit\BA Marcus Wobig\BA\BA\Decompiler\PicturePassword APK\Programm\PicturePassword_dex2jar.jar
 * Qualified Name:     com.TwinBlade.PicturePassword.AService
 * JD-Core Version:    0.6.2
 */